package cn.itsource.ymcc.service.impl;

import cn.itsource.ymcc.service.ICreateTokenService;
import cn.itsource.ymcc.util.StrUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

@Service
public class CreateTokenServiceImpl implements ICreateTokenService {
    @Autowired
    private RedisTemplate<String, String> template;
    @Override
    public String createToken(Long id) {
        String token = StrUtils.getComplexRandomString(6);
        Long loginId = 3l;
        String a = loginId+ ":" + id;
        template.opsForValue().set(a,token,10, TimeUnit.HOURS);
        return token;
    }
}
